package com.socket.client;

import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * @author luoweiyi
 *
 */
public class ClientThread extends Thread{
	
	private ObjectOutputStream dos;
	
	private Request message;
	
	public ClientThread(ObjectOutputStream dos,String name,Request message){
		super(name);
		this.dos = dos;
		this.message = message;
	}
	
	public void run(){
		
		if(null == message)
			return;
		
		try {
			
			//send request to server
			System.out.println("send request to server！");
			//send status
			dos.writeChar('s');
			//send request
			dos.writeObject(message);
			
		} catch (Exception e) {
			try {
				dos.close();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
	}
}
